package cj.web.vote.dao;
/*
 *  
 *  
*/
import java.util.List;

import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.vote.domain.VoteSongRef;

/**
 * 
 * @author 
 *
 */
@DAO
public interface VoteSongRefDAO{
	
	@SQL("SELECT * FROM VoteSongRef WHERE 1=1 "
	    	    				    		        	+ " AND voteId=:t.voteId,"
	        			    		        	+ " AND songId=:t.songId,"
	        			    		        	+ " AND type=:t.type,"
	        			    		        	+ " AND createAT=:t.createAT,"
	        			    		        	+ " AND updateAT=:t.updateAT,"
	        				+" ORDER BY update_date DESC LIMIT :t.start,:t.end ")
    List<VoteSongRef> query(@SQLParam("t") VoteSongRef voteSongRef);
    
    @SQL("select * from VoteSongRef where id=:id")
    VoteSongRef queryById(String id);
    
    @SQL("INSERT INTO VoteSongRef ("
    		        		+ "id,"
			        		+ "voteId,"
			        		+ "songId,"
			        		+ "type,"
			        		+ "createAT,"
			        		+ "updateAT,"
							+") VALUES ("
							+ ":t.id,"
							+ ":t.voteId,"
							+ ":t.songId,"
							+ ":t.type,"
							+ ":t.createAT,"
							+ ":t.updateAT,"
					+")")
    void create(@SQLParam("t") VoteSongRef voteSongRef);
	
	@SQL("UPDATE VoteSongRef SET "
		    		    						    			        + "voteId=:t.voteId,"
		        					    			        + "songId=:t.songId,"
		        					    			        + "type=:t.type,"
		        					    			        + "createAT=:t.createAT,"
		        					    			        + "updateAT=:t.updateAT,"
		        						+ " WHERE id=:t.id")
    void update(@SQLParam("t") VoteSongRef voteSongRef);
    
    @SQL("UPDATE VoteSongRef SET delete_flag=0 WHERE id=:id")
    void deleteById(String id);
}